var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all) __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if ((from && typeof from === 'object') || typeof from === 'function') {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, {
          get: () => from[key],
          enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
        });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (
  (target = mod != null ? __create(__getProtoOf(mod)) : {}),
  __copyProps(
    // If the importer is in node compatibility mode or this is not an ESM
    // file that has been converted to a CommonJS file using a Babel-
    // compatible transform (i.e. "__esModule" has not been set), then set
    // "default" to the CommonJS "module.exports" for node compatibility.
    isNodeMode || !mod || !mod.__esModule
      ? __defProp(target, 'default', { value: mod, enumerable: true })
      : target,
    mod,
  )
);
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod);

// src/Breadcrumbs/index.tsx
var Breadcrumbs_exports = {};
__export(Breadcrumbs_exports, {
  default: () => Breadcrumbs_default,
});
module.exports = __toCommonJS(Breadcrumbs_exports);
var import_HomeOutlined = __toESM(require('@ant-design/icons/HomeOutlined'));
var import_react = __toESM(require('react'));
var import_react_router_dom = require('react-router-dom');
var import_ComplexBreadcrumbs = __toESM(require('./ComplexBreadcrumbs'));
var import_SimpleBreadcrumbs = __toESM(require('./SimpleBreadcrumbs'));
var import_useMatches = __toESM(require('./useMatches'));
function Breadcrumbs({
  pathname = '/',
  params,
  base,
  routes,
  mode = 'simple',
  clickable = true,
  empty = null,
  ...rest
}) {
  var _a;
  const matches = (0, import_useMatches.default)({
    pathname,
    base,
    routes,
  });
  const breadcrumbItems = (0, import_react.useMemo)(() => {
    const items = clickable
      ? matches.map((route) => ({
          path: route.path,
          title:
            route.target ||
            (0, import_react_router_dom.generatePath)(route.path, params) !== route.path
              ? route.title
              : /* @__PURE__ */ import_react.default.createElement(
                  import_react_router_dom.Link,
                  { to: route.path },
                  route.path === '/' && !route.title
                    ? /* @__PURE__ */ import_react.default.createElement(
                        import_HomeOutlined.default,
                        null,
                      )
                    : route.title,
                ),
          onClick: () => {
            if (route.target) {
              window.location.href = route.target;
            }
          },
          route,
        }))
      : matches.map((route) => ({
          path: route.path,
          title: route.title,
          route,
        }));
    return items;
  }, [matches, params]);
  if (
    !matches.length ||
    ((_a = matches[matches.length - 1]) == null ? void 0 : _a.breadcrumb) === false
  ) {
    return empty;
  }
  return mode === 'simple'
    ? /* @__PURE__ */ import_react.default.createElement(import_SimpleBreadcrumbs.default, {
        ...rest,
        items: breadcrumbItems,
      })
    : /* @__PURE__ */ import_react.default.createElement(import_ComplexBreadcrumbs.default, {
        ...rest,
        items: breadcrumbItems,
      });
}
Breadcrumbs.SimpleBreadcrumbs = import_SimpleBreadcrumbs.default;
Breadcrumbs.ComplexBreadcrumbs = import_ComplexBreadcrumbs.default;
var Breadcrumbs_default = Breadcrumbs;
